package com.xy.tianyu.network

import com.blankj.utilcode.util.DeviceUtils
import com.blankj.utilcode.util.EncodeUtils
import com.blankj.utilcode.util.TimeUtils
import com.xy.tianyu.utils.UniqueUtils
import com.xy.tianyu.constant.Constant
import com.xy.tianyu.utils.StringUtils
import java.text.SimpleDateFormat

/**
 * @time 2020/9/16 14:13
 * @class 描述:
 */
object ApiParams {
    /**
     * 获取新闻频道参数
     */
    fun getNewsChannelParams(): Map<String, String> {
        return mapOf(
            "u" to UniqueUtils.getNewsU(),
            "uid2" to UniqueUtils.getNewsUid2(),
            "eid" to UniqueUtils.getNewseid(),
            "sign" to Constant.NEWS_SIGN,
            "version" to Constant.NEWS_VERSION,
            "news_sdk_version" to Constant.NEWS_SDK_VERSION,
            "device" to Constant.NEWS_DEVICE,
            "sdkv" to Constant.NEWS_SDKV,
            "tabsv" to Constant.NEWS_TABSV,
            "market" to Constant.NEWS_MARKET,
            "update_time" to TimeUtils.getNowString(SimpleDateFormat("yyyy-MM-dd HH:mm:ss"))
        )
    }

    /**
     * 获取新闻列表参数
     * action 页码
     * n 一页的数量
     */
    fun getNewsListParams(newest_showtime:String,oldest_showtime:String,c:String,action:String,n:String):Map<String,String>{
        return mapOf("uid" to UniqueUtils.getNewsUid(),
            "uid2" to UniqueUtils.getNewsUid2(),
            "csid" to UniqueUtils.getNewCsid(),
            "eid" to UniqueUtils.getNewseid(),
            "sign" to Constant.NEWS_SIGN,
            "version" to Constant.NEWS_VERSION,
            "market" to Constant.NEWS_MARKET,
            "news_sdk_version" to Constant.NEWS_SDK_VERSION,
            "stype" to Constant.NEWS_STYPE,
            "net" to Constant.NEWS_NET,
            "sdkv" to Constant.NEWS_SDKV,
            "device" to Constant.NEWS_DEVICE,
            "v" to Constant.NEWS_V,
            "sv" to Constant.NEWS_SV,
            "n" to n,
            "newest_showtime" to  newest_showtime,
            "oldest_showtime" to oldest_showtime,
            "c" to c,
            "scene" to Constant.NEWS_SCENE,
            "sub_scene" to Constant.NEWS_SUB_SCENE,
            "refer_scene" to Constant.NEWS_REFER_SCENE,
            "refer_subscene" to Constant.NEWS_REFER_SUBSCENE,
            "action" to action,
            "user_mode" to Constant.NEWS_USER_MODE,
            "s_enid" to Constant.NEWS_S_ENID,
            "s_dn" to EncodeUtils.base64Encode2String(DeviceUtils.getModel().toByteArray()),
            "s_av" to DeviceUtils.getSDKVersionName(),
            "performance" to "",
            "brand" to  EncodeUtils.base64Encode2String(DeviceUtils.getManufacturer().toByteArray()),
            "ufrom" to Constant.NEWS_UFROM,
            "tj_deeplink" to Constant.NEWS_TJ_DEEPLINK,
            "imgtype" to Constant.NEWS_IMGTYPE
        )
    }

    /**
     * 视频列表参数获取
     */
    fun getVideoListParams(newest_showtime:String,oldest_showtime:String,c:String,action:Int,n:Int):Map<String,String>{
        return mapOf("uid" to UniqueUtils.getNewsUid(),
            "m" to Constant.VIDEO_M,
            "browser_llq_eventmd5" to UniqueUtils.getVideoBrowserLlqEventmd5(),
            "vvs" to Constant.VIDEO_VVS,
            "browser_llq_video_tag" to Constant.VIDEO_BROWSER_LLQ_VIDEO_TAG,
            "uid2" to UniqueUtils.getNewsUid2(),
            "csid" to UniqueUtils.getNewCsid(),
            "eid" to UniqueUtils.getNewseid(),
            "sign" to Constant.NEWS_SIGN,
            "version" to Constant.NEWS_VERSION,
            "market" to Constant.VIDEO_MARKET,
            "news_sdk_version" to Constant.NEWS_SDK_VERSION,
            "stype" to Constant.NEWS_STYPE,
            "net" to Constant.NEWS_NET,
            "sdkv" to Constant.NEWS_SDKV,
            "device" to Constant.NEWS_DEVICE,
            "v" to Constant.NEWS_V,
            "sv" to Constant.NEWS_SV,
            "n" to n.toString(),
            "newest_showtime" to  newest_showtime,
            "oldest_showtime" to oldest_showtime,
            "c" to c,
            "scene" to Constant.NEWS_SCENE,
            "sub_scene" to Constant.NEWS_SUB_SCENE,
            "refer_scene" to Constant.NEWS_REFER_SCENE,
            "refer_subscene" to Constant.NEWS_REFER_SUBSCENE,
            "action" to action.toString(),
            "user_mode" to Constant.NEWS_USER_MODE,
            "s_enid" to Constant.NEWS_S_ENID,
            "s_dn" to EncodeUtils.base64Encode2String(DeviceUtils.getModel().toByteArray()),
            "s_av" to DeviceUtils.getSDKVersionName(),
            "performance" to "",
            "brand" to  EncodeUtils.base64Encode2String(DeviceUtils.getManufacturer().toByteArray()),
            "access_token" to UniqueUtils.getVideoAccessToken(),
            "ufrom" to Constant.NEWS_UFROM,
            "tj_deeplink" to Constant.NEWS_TJ_DEEPLINK,
            "imgtype" to Constant.NEWS_IMGTYPE)
    }

    fun getNovelHeaders():MutableMap<String,String>{
        val device = android.os.Build.MODEL
        val map = mutableMapOf<String,String>()
        map["appname"] = "cxb"
        map["brand"] = device.split(" ")[0]
        map["channelId"] = "1272"
        map["cnid"] = Constant.NOVEL_CNID
        map["imei"] = UniqueUtils.getNovelIMEI()
        map["imsi"] = ""
        map["mac"] = UniqueUtils.getNovelMac()
        map["model"] = device.split(" ")[1]
        map["oaid"] = ""
        map["oscode"] = "22"
        map["other"] = "a"
        map["packname"] = "com.mianfeia.book"
        map["platform"] = "android"
        map["preference"] = "1"
        map["uid"] = UniqueUtils.getNovelUid()
        map["umeng"] = "FreeShu_qq"
        map["vcode"] = "120"
        map["version"] = Constant.NOVEL_VERSION
        return map
    }

}